<?php

namespace App\Http\Requests;

class AdminRequest extends Request
{

	public function authorize()
	{
		return true;
	}

	public function rules()
	{
		return [
			'number' => 'sometimes|required|between:6,18|alpha_dash|unique:admin,number',
			'password' => 'sometimes|alpha_dash|between:6,32',
			'password_confirmed' => 'sometimes|confirmed',
			'status' => 'in:1,2',
			'tel' => [
				'required',
				'regex:/^1[3|4|5|8][0-9]\d{4,8}$/',
			],
			'email' => 'email',
		];
	}

	/**
	 * 自定义错误信息
	 */
	public function messages()
	{
		return [
			'number.required' => '账户不能为空',
			'number.between' => '账户在6到18位',
			'number.alpha_dash' => '账户为数字,字母,下划线,中划线',
			'number.unique' => '账户已存在',
			'password.alpha_dash' => '密码为数字,字母,下划线,中划线',
			'password.between' => '密码为6-32位',
			'password_confirmed.confirmed' => '两次密码输入不一致',
			'status.in' => '状态值错误',
			'tel.required' => '手机号码必填',
			'tel.regex' => '手机号码格式错误',
			'email.email' => '邮箱格式错误',
		];
	}
}